package day4;

public class Teacher {
    // 属性私有private，只能在类的内部访问
    private int id;
    private String name;
    private int age;
    private double salary;

    public void setAge(int age) {
        // The value age assigned to 'age' is never used
        // Variable 'age' is assigned to itself
        // 就近原则，这两个age都是参数的age
        // age = age;
        // this.age代表属性的age
        if (age >= 0 && age <= 150) {
            this.age = age;
        }
    }

    public int getAge() {
        return age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public void teach() {
        System.out.println("Teacher.teach");
    }

    public String printInfo() {
        //System.out.println("{id: "+id+", name: "+name+", age: "+age+", salary: "+salary+"}");
        return "Teacher{id: "+id+", name: "+name+", age: "+age+", salary: "+salary+"}";
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }
}
